//1产品分类
const String productCategoriesQuery = """
  query ProductCategories(\$after: String, \$slugs: [String!]) {
    productCategories(first: 100, after: \$after, where: {slug: \$slugs}) {
      pageInfo {
        hasNextPage
        endCursor
      }
      nodes {
        id
        databaseId
        name
        slug
        description
        image {
          sourceUrl
        }
      }
    }
  }
""";

const Map<String, dynamic> productCategoriesVariables = {
  'after': null,
  'slugs': null,
  // 'slugs': [
  //   "run-at-same-time",
  //   "thermostatic-shower-valve",
  //   "shower-body-jets",
  //   "shower-accessories",
  //   "shower-valve-cartridges",
  //   "large-shower-head",
  // ],
};

//2------------------------------------
const String productEdges = """
  edges {
    node {
      databaseId
      name
      averageRating
      slug
      ... on SimpleProduct {
        price
        regularPrice
        stockStatus
      }
      sku
      image {
        sourceUrl
      }
      ... on VariableProduct {
        price
        regularPrice
        stockStatus
      }
    }
  }
""";

const String newProductsQuery = """
{
  newProducts: products(first: 10, where: {orderby: {field: DATE, order: DESC}}) {
    $productEdges
  },
  featuredProducts: products(first: 10, where: {featured: true}) {
    $productEdges
  },
  bestSellingProducts: products(first: 10, where: {orderby: {field: TOTAL_SALES, order: DESC}}) {
    $productEdges
  }
}
""";

//3------------------------------------
const String productsQuery = """
query GetProductsByCategorySlug(\$first: Int, \$after: String, \$orderby: [ProductsOrderbyInput],
  \$featured: Boolean, \$categorySlug: String) {
  products(
    first: \$first
    after: \$after
    where: {orderby: \$orderby, category: \$categorySlug, featured: \$featured}
  ) {
    pageInfo {
      hasNextPage
      endCursor
      offsetPagination {
        total
      }
    }
    edges {
      node {
        databaseId
        name
        slug
        averageRating
        image {
          sourceUrl
        }
        shortDescription
        ... on SimpleProduct {
          price
          salePrice
          regularPrice
          stockStatus
          galleryImages {
            nodes {
              sourceUrl
            }
          }
          productCategories {
            edges {
              node {
                name
                slug
              }
            }
          }
        }
        ... on VariableProduct {
          price
          salePrice
          regularPrice
          galleryImages {
            nodes {
              sourceUrl
            }
          }
          stockStatus
          productCategories {
            edges {
              node {
                name
                slug
              }
            }
          }
        }
      }
    }
  }
}
""";

//4------------------------------------
const String postQuery = """
    query GetPosts(\$first: Int, \$after: String, \$categoryName: String) {
      posts(first:\$first,after:\$after,where:{ categoryName: \$categoryName}) {
        pageInfo {
          hasNextPage
          endCursor
          offsetPagination {
            total
          }
        }
        nodes {
          databaseId
          slug
          title
          date
          content
          commentCount
          featuredImage {
            node {
              sourceUrl
            }
          }
          author {
            node {
              name
              databaseId
            }
          }
          categories {
            nodes {
              name
              slug
            }
          }
        }
      }
    }
  """;
